package io.github.uicdb.flame_driven.common.recipe;

import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;

public interface SingleInputContainer extends Container {
    @Nonnull
    ItemStack getItemStack();
    void setItem(ItemStack item);
    @Override
    default int getContainerSize() {
        return 1;
    }

    @Override
    default boolean isEmpty() {
        getItemStack();
        return getItemStack().isEmpty();
    }

    @NotNull
    @Override
    default ItemStack getItem(int pIndex) {
        return getItemStack();
    }

    @NotNull
    @Override
    default ItemStack removeItem(int pIndex, int pCount) {
        var item= getItemStack().split(pCount);
        setChanged();
        return item;
    }

    @NotNull
    @Override
    default ItemStack removeItemNoUpdate(int pIndex) {
        ItemStack itemStack=getItemStack().copy();
        setItem(ItemStack.EMPTY);
        return itemStack;
    }

    @Override
     default void setItem(int pIndex, @NotNull ItemStack pStack) {
        setItem(pStack);
    }

    @Override
    default boolean stillValid(@NotNull Player pPlayer) {
        return true;
    }

    @Override
    default void clearContent() {
        setItem(ItemStack.EMPTY);
    }
}
